package com.qf.handerException;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author Ypl
 * @version V1.0
 * @Project September-mavens
 * @Package com.qf.handerException
 * @Description:
 * @Date 2022/10/8 15:47
 */
@SuppressWarnings("all")
public class MyExceprion implements HandlerExceptionResolver {

    @Override
    public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
        //打印异常信息
        ex.printStackTrace();

        ModelAndView mv = new ModelAndView();
        mv.addObject("error","服务器异常，请联系管理员");
        mv.setViewName("/error.jsp");
        return mv;
    }
}
